#include "PlainCodecStream.h"

#include <fstream>

using namespace Huffman;

PlainCodecStream::PlainCodecStream(std::string fileName) : CodecStream(fileName)
{
	fileStream = new std::fstream(this->getFileName(), std::fstream::in | std::fstream::out);
}

PlainCodecStream::~PlainCodecStream(void)
{
	// empty destructor
}

int PlainCodecStream::read() 
{
	return fileStream->get();
}

void PlainCodecStream::write(byte b) 
{
	fileStream->put(b);
}

int PlainCodecStream::readInt()
{
	// TODO implement
	return -1;
}

void PlainCodecStream::writeInt(int val)
{
	// TODO implement
}

void PlainCodecStream::read(byte* buffer, int offset, int size){	
	fileStream->read(buffer, size);
}

void PlainCodecStream::write(byte* buffer, int offset, int size) 
{
	fileStream->write(buffer, size);
}

void PlainCodecStream::close() {

	fileStream->close();
}